---
import { BaseLayout } from '../layouts';
import { ErrorSection } from '../components';
import { SITE_BASE_URL } from '../constants';
import { getCurrentLang } from '../utils';

const langDefault = getCurrentLang();
const langKey = langDefault.startsWith('zh') ? 'zh' : 'en';

const texts = {
  zh: {
    title: '页面未找到',
    description: '你访问的页面不存在。',
    home: '返回首页'
  },
  en: {
    title: 'Page Not Found',
    description: "The page you're looking for doesn't exist.",
    home: 'Go Home'
  }
};

const dict = texts[langKey];
const titleZh = texts.zh.title;
const titleEn = texts.en.title;
const descriptionZh = texts.zh.description;
const descriptionEn = texts.en.description;
const title = dict.title;
const description = dict.description;
---

<BaseLayout
  lang={langDefault}
  titleZh={titleZh}
  titleEn={titleEn}
  title={title}
  description={description}
  canonical={`${SITE_BASE_URL}/404`}
  metaRobots="noindex, nofollow"
>
  <ErrorSection
    code="404"
    emoji="🔍"
    title={{ zh: titleZh, en: titleEn }}
    description={{ zh: descriptionZh, en: descriptionEn }}
    homeLabel={{ zh: texts.zh.home, en: texts.en.home }}
  />
</BaseLayout>
